package com.ly.honor.controller;

import com.ly.honor.entity.Country;
import com.ly.honor.entity.Education;
import com.ly.honor.service.EducationService;

import com.ly.honor.util.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * (Education)表控制层
 *
 * @author makejava
 * @since 2023-03-14 18:04:18
 */
@RestController
@RequestMapping("education")
@Api(tags = "学历管理")
public class EducationController {
    /**
     * 服务对象
     */
    @Resource
    private EducationService educationService;

    @GetMapping("selectEducationAll")
    @ApiOperation("查询所有学历信息")
    public Result selectEducationAll(){
        return Result.ok(educationService.list());
    }

    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @GetMapping("getEducationById/{id}")
    public Result getEducationById(@PathVariable Integer id) {
        return Result.ok(this.educationService.getById(id));
    }

    /**
     * 新增数据
     *
     * @param education 实体对象
     * @return 新增结果
     */
    @PostMapping("insertEducation")
    public Result insertEducation(@RequestBody Education education) {
        return Result.ok(this.educationService.save(education));
    }

    /**
     * 修改数据
     *
     * @param education 实体对象
     * @return 修改结果
     */
    @PostMapping("updateEducation")
    public Result updateEducation(@RequestBody Education education) {
        return Result.ok(this.educationService.updateById(education));
    }

    /**
     * 删除数据
     *
     * @param id 主键
     * @return 删除结果
     */
    @DeleteMapping("deleteEducationById/{id}")
    public Result deleteEducationById(@PathVariable Integer id) {
        return Result.ok(this.educationService.removeById(id));
    }




}

